package to.pm.web.bil;

import java.util.HashMap;
import java.util.Map;
import to.pm.magazzino.bi.GestioneMagazzinoBusiness;


public class MagazzinoBean implements MagazzinoBI {


    /// DI dell'EJB3 via spring
    private GestioneMagazzinoBusiness magazzinoService;

    public GestioneMagazzinoBusiness getMagazzinoService() {
        return magazzinoService;
    }

    public void setMagazzinoService(GestioneMagazzinoBusiness magazzinoService) {
        this.magazzinoService = magazzinoService;
    }


    ///
    public Map getCollocazioniMap() {
        Map mdi = magazzinoService.findAllCollocazioniMap();
        Map mid = new HashMap();

        //JSF e Struts2 usano Map in modo invertito per i tag tipo select...
        Map.Entry entry;
        for (Object e : mdi.entrySet()) {
           entry = (Map.Entry) e;
           mid.put(entry.getValue(),entry.getKey());
        }

        return mid;
    }


    public Map getDisponibilitaMap() {
        Map mdi = magazzinoService.findDisponibilitaByCollocazioneMap(null);
        Map mid = new HashMap();

        //JSF e Struts2 usano Map in modo invertito per i tag tipo select...
        Map.Entry entry;
        for (Object e : mdi.entrySet()) {
           entry = (Map.Entry) e;
           mid.put(entry.getValue(),entry.getKey());
        }

        return mid;
    }

}
